-
-
Notifications
You must be signed in to change notification settings - Fork 33k
module: add module.customConditions #57688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Review requested:
|
9efaba7
to
6f23b07
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #57688 +/- ##
==========================================
- Coverage 89.96% 89.86% -0.11%
==========================================
Files 640 657 +17
Lines 188454 193287 +4833
Branches 36892 37921 +1029
==========================================
+ Hits 169546 173698 +4152
- Misses 11608 12110 +502
- Partials 7300 7479 +179
🚀 New features to boost your workflow:
|
6f23b07
to
6bbb2e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in order to address the primordial issue, you need to use SafeSet
within getUserConditions
, and then within the getter, wrap the output of getUserConditions
in Set
.
This should help with nodejs#57688 and others
I put up #57723 as a potential way to easily convert a SafeSet to a user-exposable Set, which might help this PR. |
This should help with nodejs#57688 and others
6bbb2e1
to
cae9e94
Compare
Thanks for the reviews! |
66cc00b
to
0789c21
Compare
Thanks, I've updated the code! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would i polyfill this in a node that doesn’t have it? Would i have to trawl through NODE_OPTIONS and process.argv and the config file, or is there an easier way?
This comment was marked as outdated.
This comment was marked as outdated.
As far as I know, that’s the only way. |
This comment was marked as outdated.
This comment was marked as outdated.
cac31a9
to
0986bde
Compare
be5a488
to
05d07df
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think https://github.com/sapphi-red/node/blob/05d07dfb01ad34bfe1d236505b627d6f4465fd74/doc/api/cli.md?plain=1#L477-L502 will need to be updated.
I have never heard of this CLI option before, and neither the docs in this PR nor the docs I have linked make things clear to me.
861529e
to
e87d6f5
Compare
Add module.customConditions which exposes the custom resolution conditions specified by the user. Fixes: nodejs#55824
e87d6f5
to
d576f5c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a really useful feature to have, and I would happily approve progress here.
One problem we have when interacting with loaders though is that the custom conditions of the outer context and inner context might be different when using VM or future loader hook constructs.
The way to resolve this future conflict would be to put this on import.meta
instead of as a property - import.meta.customConditions
. The justification being the same as for import.meta.resolve()
effectively. The process on that would require its own approval going through https://github.com/WinterTC55/import-meta-registry though, which may be harder than this PR. I'm on the fence on this requirement, but it's worth discussing while we are working this through.
My preference would also be to expose this as a frozen array rather than a mutable set to ensure it is correct.
Add
module.customConditions
which exposes the custom resolution conditions specified by the user.Fixes: #55824